package nc.tb.consolidate;

import nc.tb.dim.DimMember;
import nc.tb.pub.BusiObj;

public class EntityVector extends BusiObj {
	private DimMember selfentity = null;

	private DimMember otherentity = null;

	public String getType() {
		return "EntityVector";
	}

	public void setSelfEntity(DimMember dm) {
		selfentity = dm;
	}

	public void setOtherEntity(DimMember dm) {
		otherentity = dm;
	}

	public DimMember getSelfEntity() {
		return selfentity;
	}

	public DimMember getOtherEntity() {
		return otherentity;
	}
	public int hashCode() {
		if (selfentity == null || otherentity==null)
			return 0;
//		return selfentity.hashCode()+otherentity.hashCode();
		return (selfentity.getPrimaryKey() + otherentity.getPrimaryKey()).hashCode();
	}
	public String toString() {
		return selfentity.getObjname() + " vs " + otherentity.getObjname();
	}

	public boolean equals(Object b){
		if(!(b instanceof BusiObj))return false;
		BusiObj bo=(BusiObj)b;
		String pk1=getSelfEntity().getPrimaryKey()+getOtherEntity().getPrimaryKey();
		String pk2=((EntityVector)bo).getSelfEntity().getPrimaryKey()+((EntityVector)bo).getOtherEntity().getPrimaryKey();
		if(pk1==null&& pk2==null)return true;
		if(pk1==null && pk2!=null)return false;
		if(pk1!=null && pk2==null)return false;
		return pk1.equals(pk2);
	}

}
